package com.jsmile.cloud.authc.sys;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jsmile.cloud.authc.api.req.sys.ReqSysLogQuery;
import com.jsmile.cloud.authc.api.res.ResSysLog;
import com.jsmile.cloud.authc.sys.repo.SysLogSearchRepository;
import com.jsmile.mall.api.exception.ExceptionKit;

import cn.hutool.core.bean.BeanUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service
@AllArgsConstructor
public class SysLogApplicationService {

    private final SysLogSearchRepository sysLogSearchRepository;

    public IPage<ResSysLog> getPageList(ReqSysLogQuery reqSysLogQuery) {
        ExceptionKit.checkNotNull(reqSysLogQuery.getCurTenantId(), "租户id不能为空!");
        log.info("日志查询:{]", reqSysLogQuery);
        return sysLogSearchRepository.pageQuery(reqSysLogQuery).convert(x -> BeanUtil.toBean(x, ResSysLog.class));
    }
}
